package seu.evaluation.metric;

import seu.xml.analysis.Diagram;
import seu.xml.analysis.UMLERDiagram;
import seu.xml.validator.GlobalCons;
/**
 * 
 * @author samantha
 * 可靠性度量入口
 *
 */
public class ReliabilityMetric extends Metric {
	ReliabilityDiagramInfo diagramInfo = new ReliabilityDiagramInfo();
	ReliabilityMetricStrategy rmetric = new ReliabilityMetricStrategy(); 
	
	public ReliabilityMetric(){
		Diagram dg ;	
	
		/**
		 * 用例图解析
		 */
		//假设只有一张系统级用例图
		for( String ucPath : GlobalCons.ucDiagramPath ){
			dg = new Diagram();
			dg.readXML( ucPath );
			diagramInfo.sequenceToUsecase();
			System.out.println("----------------------------------用例图解析结束------------------------");
		}
		
		/**
		 * 部署图解析
		 */
		//假设只有一张系统级部署图
		for( String dpPath : GlobalCons.dplmtDiagramPath ){
			dg = new Diagram();
			dg.readXML( dpPath );
			diagramInfo.deploymentAnalysis( new UMLERDiagram(dg));
			System.out.println("----------------------------------部署图解析结束------------------------");
		}
		
		
		/**
		 * 顺序图解析
		 */
		//如何判断是相应的顺序图？
		for( String ssPath : GlobalCons.sqcDiagramPath){
			dg = new Diagram();
			dg.readXML( ssPath );
			diagramInfo.sequenceAnalysis(  new UMLERDiagram(dg),ssPath );
			System.out.println("----------------------------------顺序图解析结束------------------------");
		}

		results.add( rmetric.run(diagramInfo) );	
	}
	
	public static void main( String args[] ){
		
		GlobalCons.ucDiagramPath.add("UsecaseDiagram.uxf");
		GlobalCons.dplmtDiagramPath.add("DeploymentDiagram.uxf");
		GlobalCons.sqcDiagramPath.add("LocalOperationSd.uxf");
		GlobalCons.sqcDiagramPath.add("RemoteReadSd1.uxf");
		GlobalCons.sqcDiagramPath.add("RemoteReadSd2.uxf");
		GlobalCons.sqcDiagramPath.add("RemoteWriteSd.uxf");
		
		/*
		GlobalCons.ucDiagramPath.add("Use case.uxf");
		GlobalCons.dplmtDiagramPath.add("Deployment.uxf");
		GlobalCons.sqcDiagramPath.add("Sequence_transaction.uxf");
		GlobalCons.sqcDiagramPath.add("Sequence_system_shutdown.uxf");
		GlobalCons.sqcDiagramPath.add("Sequence_system_startup.uxf");
		GlobalCons.sqcDiagramPath.add("Sequence_session.uxf");
		*/
		
		ReliabilityMetric rMetric = new ReliabilityMetric();
		System.out.println("\n\n~~~~~~~~~~~~~~~~~~~~~~~~~Reliability Result~~~~~~~~~~~~~~~~~~~~~~~~");
		rMetric.showResults();
		System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~Reliability Result End~~~~~~~~~~~~~~~~~~~~~~~~");
	}
}
